var e = n(require("../../@babel/runtime/regenerator")),
  a = require("../../@babel/runtime/helpers/asyncToGenerator"),
  t = n(require("@/config/index")),
  r = n(require("@/config/page")),
  o = require("@/services/appreciation-service"),
  i = require("@/utils/report");
function n(e) {
  return e && e.__esModule ? e : { default: e };
}
Page({
  data: {
    background: "transparent",
    iconTheme: "white",
    CDN: t.default.CDN,
    position: !0,
    tab: 0,
    circleCurrent: 0,
    info: {},
    lifeIndex: 0,
    current: 0,
    lastcurrent: 0,
    startTime: 0,
    isShowLifeCard: !1,
    lifeActiveIndex: 0,
    isShowUnearthCard: !1,
    unearthActiveIndex: 0,
    isShowUnearthBar: !1,
    tapLife: !1,
  },
  onShareAppMessage: function () {
    return {
      title: t.default.share.title,
      imageUrl: t.default.share.pic,
      path: r.default.PAGE_APPRECIATION_INDEX,
    };
  },
  onShow: function () {
    var e,
      a,
      t = this;
    this.setData({ startTime: Date.now(), startTimeTwo: Date.now() });
    var r,
      o,
      i = getApp();
    null != i &&
      null !== (e = i.globalData) &&
      void 0 !== e &&
      null !== (a = e.tabBarParam) &&
      void 0 !== a &&
      a.isFromTabBar &&
      (0 ===
      (null == i ||
      null === (r = i.globalData) ||
      void 0 === r ||
      null === (o = r.tabBarParam) ||
      void 0 === o
        ? void 0
        : o.tab)
        ? this.onFeatured()
        : this.onMore(),
      (i.globalData.tabBarParam.tab = 0),
      (i.globalData.tabBarParam.current = 0),
      (i.globalData.tabBarParam.isFromTabBar = !1));
    "function" == typeof this.getTabBar &&
      this.getTabBar() &&
      this.getTabBar().setData({ selected: 2 }, function () {
        t.getTabBar().play();
      }),
      this.init();
  },
  onHide: function () {
    console.log("隐藏页面");
    var e = Date.now(),
      a = this.data,
      t = a.startTime,
      r = a.current,
      o = e - t;
    1 === r
      ? (0, i.report)("apage_modulea_show", { time: o })
      : 2 === r
        ? (0, i.report)("apage_moduleb_show", { time: o })
        : 3 === r
          ? (0, i.report)("apage_modulec_show", { time: o })
          : 4 === r
            ? (0, i.report)("apage_moduled_show", { time: o })
            : 0 === r && (0, i.report)("apage_show", { time: o });
  },
  onUnload: function () {
    console.log("卸载页面");
    var e = Date.now(),
      a = this.data,
      t = a.startTime,
      r = a.current,
      o = e - t;
    1 === r
      ? (0, i.report)("apage_modulea_show", { time: o })
      : 2 === r
        ? (0, i.report)("apage_moduleb_show", { time: o })
        : 3 === r
          ? (0, i.report)("apage_modulec_show", { time: o })
          : 4 === r
            ? (0, i.report)("apage_moduled_show", { time: o })
            : 0 === r && (0, i.report)("apage_show", { time: o });
  },
  init: function () {
    var t = this;
    return a(
      e.default.mark(function a() {
        var r;
        return e.default.wrap(function (e) {
          for (;;)
            switch ((e.prev = e.next)) {
              case 0:
                return (e.next = 2), (0, o.getAppreciationInfo)();
              case 2:
                (r = e.sent),
                  t.setData({
                    info: r,
                    isShowUnearthCard: !1,
                    isShowLifeCard: !1,
                  });
              case 4:
              case "end":
                return e.stop();
            }
        }, a);
      }),
    )();
  },
  onFeatured: function () {
    var e,
      a,
      t = getApp();
    this.setData({
      tab: 0,
      current:
        0 |
        (null == t ||
        null === (e = t.globalData) ||
        void 0 === e ||
        null === (a = e.tabBarParam) ||
        void 0 === a
          ? void 0
          : a.current),
      iconTheme: "white",
      position: !0,
      background: "transparent",
    }),
      this.getTabBar().checkBg(!1),
      wx.setBackgroundColor({ backgroundColor: "#0C1411" });
  },
  onMore: function () {
    this.setData({
      tab: 1,
      iconTheme: "black",
      background: "#F7F0E4",
      position: !1,
    }),
      (0, i.report)("apage_all_show", {}),
      this.getTabBar().checkBg(!0),
      wx.setBackgroundColor({ backgroundColor: "#F7F0E4" });
  },
  onShowLifeCard: function (e) {
    var a = e.detail.activeIndex;
    this.setData({ isShowLifeCard: !0, lifeActiveIndex: a });
  },
  onShowUnearthCard: function (e) {
    var a = e.detail.activeIndex;
    this.setData({ isShowUnearthCard: !0, unearthActiveIndex: a });
  },
  onShowUnearthMore: function (e) {
    var a = e.detail.activeIndex;
    this.setData({ isShowUnearthBar: !0, unearthActiveIndex: a });
  },
  showEarth: function (e) {
    var a = e.detail.current,
      t = this.data,
      r = t.lastcurrent,
      o = t.startTime,
      n = this.data.current,
      s = Date.now(),
      u = s - o;
    this.setData({ current: a, lastcurrent: n, stayTime: s });
    var h = this.data.tapLife;
    1 === a && this.setData({ tapLife: !h }),
      1 === r
        ? (0, i.report)("apage_modulea_show", { time: u })
        : 2 === r
          ? (0, i.report)("apage_moduleb_show", { time: u })
          : 3 === r
            ? (0, i.report)("apage_modulec_show", { time: u })
            : 4 === r
              ? (0, i.report)("apage_moduled_show", { time: u })
              : 0 === r && (0, i.report)("apage_show", { time: u });
  },
  onCloseLifeCard: function () {
    this.setData({ isShowLifeCard: !1 });
  },
  onCloseUnearthBar: function () {
    this.setData({ isShowUnearthBar: !1 });
  },
  onCloseUnearthCard: function (e) {
    var a = e.detail.activeIndex;
    this.setData({ isShowUnearthCard: !1, unearthActiveIndex: a });
  },
  onChoice: function (e) {
    var a = e.detail.activeIndex;
    this.setData({ unearthActiveIndex: a });
  },
});
